
import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        fun(n);
        System.out.println();
        fun1(n);
    }
    public static void fun(int n) {
        if(n / 10 == 0) {
            System.out.print(n + " ");
            return ;
        }
        fun(n/10);
        System.out.print(n % 10 + " ");
    }
    public static void fun1(int n) {
        if(n / 10 != 0) {
           fun1(n/10);
        }
        System.out.print(n % 10 + " ");
    }
}
